<%@ page import="java.util.List" %>
<%@ page import="pojo.*" %>
<%@ page import="util.PageUtil" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/13
  Time: 22:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style type="text/css">
        table {
            border-collapse: collapse;
        }
        a:link {
            text-decoration: none;
        }

        a:visited {
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        a:active {
            text-decoration: underline;
        }
        #customers {
            font-family: Arial, Helvetica, sans-serif;
            border-collapse: collapse;
            width: 100%;
        }

        #customers td, #customers th {
            border: 1px solid #ddd;
            padding: 8px;
        }

        #customers tr:nth-child(even){background-color: #f2f2f2;}

        #customers tr:hover {background-color: #ddd;}

        #customers th {
            padding-top: 12px;
            padding-bottom: 12px;
            text-align: left;
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>
<script>
    function SearchByContent(){
        var key=document.getElementById("content").value;
        location.href="/TcmSystem/ShtbServlet?action=search&flag=0&key="+key;
    }
    function SearchByComment(){
        var key=document.getElementById("comment").value;
        location.href="/TcmSystem/ShtbServlet?action=search&flag=1&key="+key;
    }
    function del(id){
        if(confirm("确认删除该条辩的记录吗?")){
            location.href="/TcmSystem/ShtbServlet?action=delete&id="+id;
        }
    }
</script>
<body>
<%
    PageUtil pu=(PageUtil)request.getAttribute("shtbList");
    List<ShangHanTiaoBian> list =pu.getList();
    int curPage=(int)request.getAttribute("curPage");
%>
<h1 align="center">伤寒条辩展示</h1>

<form action="#" method="post">
<table align="center" >
    <tr>
        <td>
            内容查询:
            <input type="text" id="content" name="content"/>
            <input type="button" value="查询" onclick="SearchByContent();">
        </td>
        <td>
            注释查询:
            <input type="text" id="comment" name="comment"/>
            <input type="button" value="查询" onclick="SearchByComment();">
        </td>
    </tr>
</table>
</form>

<table id="customers" align="center" border="2" width="1000px">
    <tr>
        <td>编号</td>
        <td>内容</td>
        <td>注释</td>
        <td>方法</td>
        <%--<th>类型</th>--%>
    </tr>
    <%for(ShangHanTiaoBian shtb:list){%>
    <tr>

        <td><%=shtb.getNum()%></td>
        <td><%=shtb.getContent()%></td>
        <td><%=shtb.getComment()%></td>
        <td>
            <a href="ShtbServlet?action=detail&tbid=<%=shtb.getId()%>">详情</a>&nbsp
            <a href="ShtbServlet?action=editUI&id=<%=shtb.getId()%>">编辑</a>&nbsp
            <a href="#" onclick="del(<%=shtb.getId()%>)">删除</a>&nbsp
        </td>
    </tr>
    <%}%>
</table>
<div align="center">
    第<%=curPage%>页
</div>
<div align="center">
    <a href="/TcmSystem/ShtbServlet?action=list&curPage=<%=pu.getPrev()%>">上一页</a>
    <a href="/TcmSystem/ShtbServlet?action=list&curPage=<%=pu.getNext()%>">下一页</a>
</div>
        <br/>
        <div align="center">
           <button> <a href="/TcmSystem/ShtbServlet?action=addUI">添加</a>&nbsp;</button>&nbsp;
           <button> <a href="/TcmSystem/index.jsp">返回首页</a> </button>
        </div>
</body>
</html>
